<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加等级</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/app/admin/component/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" media="all">
</head>
<body>
    <div class="layui-form" lay-filter="level-form" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">等级名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" placeholder="请输入等级名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">折扣率(%)</label>
            <div class="layui-input-block">
                <input type="number" name="discount" lay-verify="required|number" placeholder="请输入折扣率" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">积分比例</label>
            <div class="layui-input-block">
                <input type="number" name="points_rate" lay-verify="required|number" placeholder="请输入积分比例" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">升级积分</label>
            <div class="layui-input-block">
                <input type="number" name="upgrade_points" lay-verify="required|number" placeholder="请输入升级所需积分" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="启用" checked>
                <input type="radio" name="status" value="0" title="禁用">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="level-form-submit" id="LAY-level-add-submit">立即提交</button>
            </div>
        </div>
    </div>

    <script src="/app/admin/component/layui/layui.js"></script>
    <script src="/app/admin/component/pear/pear.js"></script>
    <script>
    layui.use(['form', 'layer'], function(){
        var $ = layui.$
        ,form = layui.form
        ,layer = layui.layer;
        
        //监听提交
        form.on('submit(level-form-submit)', function(data){
            var field = data.field;
            
            //提交数据
            $.ajax({
                url: '/app/ky_shouyin/member/level/add'
                ,type: 'POST'
                ,data: field
                ,success: function(res){
                    if(res.code === 0){
                        parent.layer.msg('添加成功', {icon: 1});
                        parent.layui.table.reload('LAY-level-list');
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            });
            
            return false;
        });
    });
    </script>
</body>
</html> 